<?php

namespace app\steps;

use app\admin\model\RegulateProblem;
use app\model\Project;
use think\db\Query;
use tpScriptVueCurd\base\model\BaseModel;
use tpScriptVueCurd\base\model\VueCurlModel;
use tpScriptVueCurd\field\StringField;
use tpScriptVueCurd\FieldCollection;
use tpScriptVueCurd\filter\EmptyFilter;
use tpScriptVueCurd\ModelField;
use tpScriptVueCurd\option\FieldStep;
use tpScriptVueCurd\option\FieldStepBase;
use tpScriptVueCurd\option\FieldStepBaseConfig;
use tpScriptVueCurd\option\FieldStepTag;

class Withdrawal extends FieldStepBase
{
    //列表中点击撤回按钮时，弹出的确认框
    protected string $listDirectSubmit='您确定要撤回审核吗？';

    public static function name(): string
    {
        return 'withdrawal';
    }

    public static function make(): FieldStepBase
    {
        //撤回的时候不需要用户填写信息，但这里又必须有。所以这里随便放了个字段，不在外面显示出来
        return new self([
            StringField::init('WithdrawalStepField','')
                //此字段不自动生成
                ->generateColumn(false)
                ->listShow(false)->editShow(false)->showPage(false)->filter(new EmptyFilter())
        ]);
    }

    public function config(FieldStepBaseConfig $config): void
    {
        $config->title='撤回审核';
        $config->listBtnText='撤回审核';
        $config->listBtnColor='#722ed1';
        $config->listBtnUrl=url('project/withdrawal')->build();
    }

    public function listRowDo(VueCurlModel $info, ?BaseModel $baseInfo, FieldCollection $fields, FieldStep $step): void
    {
        parent::listRowDo($info, $baseInfo, $fields, $step);
        //当前列表中步骤时执行
        $step->setTags([new FieldStepTag('等待重新编辑','cyan')]);
    }


    protected function beforeCheck(VueCurlModel $info = null, BaseModel $baseInfo = null, ModelField $field = null): bool
    {
        //需要审核过后的数据才能撤回
        return eqEndStep(Check::name(),$info);
    }


    protected function auth(VueCurlModel $info = null, BaseModel $baseInfo = null, FieldCollection $fields = null): bool
    {
        return true;
    }

    protected function authWhere(Query $query): void
    {
        // TODO: Implement authWhere() method.
    }
}